<?php
namespace App\Admin\Renderable;
use App\Admin\Repositories\Shop\WxShopGoodsProduct;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;

class ShopGoodsProductRender extends LazyRenderable
{
    public function grid(): Grid
    {
        return Grid::make(new WxShopGoodsProduct(), function (Grid $grid) {
//            global $__MINI_GLOBAL_TENANT_ID__;
//            if($__MINI_GLOBAL_TENANT_ID__ > 0){
//                $grid->model()->where('tenant_id', '=', $__MINI_GLOBAL_TENANT_ID__);
//            }
            $grid->simplePaginate();
            $grid->quickSearch(['id', 'goods_id','param_value'])->placeholder('搜索规格ID，商品ID，规格名称...')->width(30);
            $grid->model()->orderBy('id', 'desc');
            $grid->column('id')->sortable();
            $grid->column('pic')->image('',50);
            $grid->column('param_value', '规格名称');
            $grid->column('vip_price', '会员价');
            $grid->column('price', '普通价');
            $grid->column('stock', '库存');
//            $grid->column('sort');
            $grid->column('goods_id', '商品id');
//            $grid->column('state', '状态');
//            $grid->column('created_at');
            $grid->column('updated_at')->sortable();

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');
            });
            $grid->disableActions();
        });
    }
}
